package com.tencent.sr.iris.basic.mp.restapi.controller.activity;


import com.tencent.sr.iris.activity.interfaces.request.acticity.ActivityGiftPopupRequest;
import com.tencent.sr.iris.activity.interfaces.response.activity.ActivityGiftPopupResponse;
import com.tencent.sr.iris.basic.mp.interfaces.request.MpActivityGiftPopupRequest;
import com.tencent.sr.iris.basic.mp.service.activity.ActivityAwardService;
import com.tencent.sr.rmall.common.primitive.HttpResult;
import com.tencent.sr.rmall.springbootstarter.authtoken.localbean.AppUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@Api(tags = "活动权益", value = "活动权益相关接口")
@RestController
@RequestMapping("/iris/basic/mp/v1/user/award")
public class ActivityAwardController {

    @Resource
    private ActivityAwardService activityAwardService;

    @Resource
    private AppUser appUser;

    @PostMapping("popup")
    @ApiOperation("活动权益弹窗")
    public HttpResult<ActivityGiftPopupResponse> popup(
            @Validated @RequestBody MpActivityGiftPopupRequest request) {
        if(StringUtils.isEmpty(request.getUid())){
            request.setUid(appUser.getUid());
        }
        ActivityGiftPopupResponse result = activityAwardService.popup(request);
        return HttpResult.succ(result);
    }

    @Deprecated
    @PostMapping("closePopup")
    @ApiOperation("关闭权益弹窗")
    public HttpResult<Boolean> closePopup(
            @Validated @RequestBody MpActivityGiftPopupRequest request) {
        if(StringUtils.isEmpty(request.getUid())){
            request.setUid(appUser.getUid());
        }
//        Boolean result = activityAwardService.closePopup(request);
//        return HttpResult.succ(result);
        return HttpResult.succ(true);
    }
}
